package com.yxj02;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MapDemo01 {
    public static void main(String[] args) {
        Map<String,String> map = new HashMap<String,String>();
        map.put("猪八戒","孙悟空");
        map.put("西施","安琪拉");
        map.put("鲁班","芈月");
        //获取所有键的集合，用keySet()方法实现
        Set<String> keySet = map.keySet();
        //遍历键去找值
        for(String key : keySet) {
            //根据键去找值，用get(Object key)方法实现
            String value = map.get(key);
            System.out.println(key+","+value);
        }
    }
}
